home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 33
/
Volume 33 - JOGO DISK .iso
/
Games
/
pin_ball_deluxe.swf
/
scripts
/
DefineSprite_426
/
frame_1
/
DoAction.as
< prev
Wrap
Text File
|
2007-01-15
|
6KB
|
231 lines
function calculateDirection(angle)
{
var _loc4_ = _X;
var _loc2_ = _Y;
var _loc3_ = x;
var _loc1_ = y;
a = _loc1_ - _loc2_;
b = _loc4_ - _loc3_;
c = (- _loc4_) * _loc1_ + _loc3_ * _loc2_;
}
function collisionSegment()
{
var _loc2_ = segmentT.getIntersection(a,b,c);
var _loc4_ = segmentT.angle >= 90;
var _loc5_ = !_loc4_ ? segmentT.angle : 180 - segmentT.angle;
if(isCollision == true)
{
if(_loc5_ > 2)
{
speed += 1;
}
}
var _loc3_ = Math.sqrt((_loc2_.x0 - _X) * (_loc2_.x0 - _X) + (_loc2_.y0 - _Y) * (_loc2_.y0 - _Y));
_X = _loc2_.x0 - _loc3_ * (_width / 2) / actualDist * Math.cos(angle * radToDeg);
_Y = _loc2_.y0 - _loc3_ * (_width / 2) / actualDist * Math.sin(angle * radToDeg);
if(segmentT.clipObj != null)
{
segmentT.clipObj.action();
}
if(segmentT.clipObj == null)
{
segmentT.clipObj = _root.null_mc;
segmentT.clipObj.action();
}
speed += segmentT.clipObj.deltaSpeed;
angle = 2 * segmentT.angle - angle;
angle += angle >= 0 ? 0 : 360;
angle += angle <= 360 ? 0 : -360;
isCollision = true;
inactiveTuneling = true;
speedErr = 4.25;
if(speed > 6)
{
speed = speed - AMORTIZATION - speedErr;
}
if(speed > 3 && speed < 6)
{
speedErr = 1.6;
speed -= speedErr;
}
}
function collisionBall()
{
var _loc7_ = ballT._x;
var _loc6_ = ballT._y;
var _loc11_ = _width / 2;
var _loc10_ = ballT._width / 2;
var _loc5_ = _loc11_ + _loc10_;
var _loc8_ = ballT.distancePoint(this);
_X = _loc7_ + _loc5_ * (x - _loc7_) / _loc8_;
_Y = _loc6_ + _loc5_ * (y - _loc6_) / _loc8_;
var _loc4_ = (- (_X - _loc7_)) / _loc5_;
var _loc3_ = (- (_Y - _loc6_)) / _loc5_;
var _loc2_ = speedX * _loc4_ + speedY * _loc3_;
var _loc9_ = (- speedX) * _loc3_ + speedY * _loc4_;
_loc2_ *= -1;
speedX = _loc2_ * _loc4_ - _loc9_ * _loc3_;
speedY = _loc2_ * _loc3_ + _loc9_ * _loc4_;
speed = Math.sqrt(speedX * speedX + speedY * speedY) + ballT.deltaSpeed;
angle = Math.atan(Math.abs(speedY / speedX)) * 180 / 3.141593;
if(speedX < 0 && speedY < 0)
{
angle += 180;
}
else if(speedX < 0 && speedY > 0)
{
angle = 180 - angle;
}
else if(speedX > 0 && speedY < 0)
{
angle = 360 - angle;
}
if(ballT.clipObj != null)
{
ballT.clipObj.action();
}
inactiveTuneling = true;
}
function collisionFlipperRight()
{
var _loc5_ = _width / 2;
var _loc3_ = _root.flipRight.distanceTo(this);
var _loc7_ = x;
var _loc6_ = y;
var _loc4_ = Math.abs(_root.flipRight.centreX - x) / _root.flipRight.upSegment.module;
angle = 335 - Math.round(80 * _loc4_);
speed += 7 + 8 * _loc3_ / _root.flipRight.upSegment.module;
_root.flipRight.upSegment.active = false;
ballFlipped = true;
inactiveTuneling = true;
}
function collisionFlipperLeft()
{
var _loc5_ = _width / 2;
var _loc3_ = _root.flipLeft.distanceTo(this);
var _loc7_ = x;
var _loc6_ = y;
var _loc4_ = Math.abs(x - _root.flipLeft.centreX) / _root.flipLeft.upSegment.module;
angle = 205 + Math.round(80 * _loc4_);
speed += 7 + 8 * _loc3_ / _root.flipLeft.upSegment.module;
_root.flipLeft.upSegment.active = false;
ballFlipped = true;
inactiveTuneling = true;
}
function findPossibleTarget()
{
findPossibleSegmentTarget();
findPossibleBallTarget();
}
function findPossibleBallTarget()
{
tempBalls = new Array();
for(var _loc5_ in _root.allBalls2)
{
if(_root.allBalls2[_loc5_].isPossibleTarget(this))
{
tempBalls.push(_root.allBalls2[_loc5_]);
}
}
if(tempBalls.length == 1)
{
ballT = tempBalls[0];
return undefined;
}
ballMinDistance = 100000;
var _loc4_ = -1;
for(_loc5_ in tempBalls)
{
var _loc3_ = tempBalls[_loc5_].distancePoint(this);
if(_loc3_ < ballMinDistance && (_loc3_ > 0 || ballT == tempBalls[_loc5_]))
{
ballMinDistance = _loc3_;
_loc4_ = _loc5_;
}
}
if(_loc4_ != -1)
{
ballT = tempBalls[_loc4_];
}
else
{
ballT = null;
}
}
function startClip()
{
angle = startAngle;
}
function stepByStep()
{
_X = _X + stepX;
_Y = _Y + stepY;
step++;
}
function updateDestination()
{
if(inactiveTuneling == false)
{
isOnPath = false;
}
speed += speedInc == null ? 0.5 : speedInc;
if(MAX_SPEED < speed)
{
speed = MAX_SPEED;
}
antDestination = destination;
destination = _root[destination].nextStep;
if(destination == "out")
{
isOnPath = false;
angle = angleOut;
if(speedOut != null)
{
speed = speedOut;
}
}
else if(destination == "wait")
{
isOnPath = false;
speed = 0;
timeToWait = 2000;
speed_wait = _root[antDestination].speed_wait;
angle_wait = _root[antDestination].angle_wait;
sTime = getTimer();
inactiveTuneling = true;
}
else
{
deltaX = _root[destination]._x - _X;
deltaY = _root[destination]._y - _Y;
distanceToBeacon = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
steps = distanceToBeacon / speed;
stepX = deltaX / steps;
stepY = deltaY / steps;
step = 1;
}
}
function wait(time, ang_wait, spe_wait, xOut, yOut)
{
timeToWait = time;
sTime = getTimer();
angle_wait = ang_wait;
speed_wait = spe_wait;
xOutPosition = xOut;
yOutPosition = yOut;
}
radToDeg = 0.017453;
flipRightToggled = false;
flipLeftToggled = false;
speed = 0;
startAngle = 270;
GRAV_Y = 0.43;
AMORTIZATION = 1.4;
MAX_SPEED = 14;
timeToWait = null;
startClip();
ballRadius = 4.3;
activate = 0;
m = 8.6;
tempAngle = 0;